#!/bin/bash

# 批量修复编译错误脚本
echo "开始批量修复编译错误..."

# 定义需要修复的文件列表
files=(
    "fuint-application/src/main/java/com/fuint/common/service/impl/CommissionRelationServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/BalanceServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/UserActionServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/PointServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/SmsTemplateServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/BookItemServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/MemberServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/OpenGiftServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/OrderServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/CommissionCashServiceImpl.java"
    "fuint-application/src/main/java/com/fuint/common/service/impl/CommissionLogServiceImpl.java"
)

echo "需要修复的文件数量: ${#files[@]}"

# 检查文件是否存在
for file in "${files[@]}"; do
    if [ -f "$file" ]; then
        echo "✓ $file 存在"
    else
        echo "✗ $file 不存在"
    fi
done

echo ""
echo "修复建议："
echo "1. 对于 'pageResult 找不到符号' 错误："
echo "   - 添加 Page<EntityType> page = new Page<>(currentPage, pageSize);"
echo "   - 添加 Page<EntityType> pageResult = mapper.selectPage(page, lambdaQueryWrapper);"
echo ""
echo "2. 对于类型不兼容错误："
echo "   - 使用 PageImpl 和 PageRequest 替代直接传递 MyBatis Plus Page"
echo "   - 添加类型转换: (int) pageResult.getPages()"
echo ""
echo "3. 对于 long 转 int 错误："
echo "   - 添加强制类型转换: (int) longValue"
echo ""

echo "请手动修复这些文件，或者使用 IDE 的查找替换功能进行批量修复。"
